package code.search

fun main() {

}

//找到第一个isBadVersion（）== true
fun firstBadVersion(n: Int): Int {
    var left = 0
    var right = n
    while (left <= right) {
        var mid = (left + right) / 2
        if (isBadVersion(mid)) { //当前版本是坏的
            right = mid
        } else {
            //当前版本是好的
            left = mid + 1
        }
    }
    return left
}

fun isBadVersion(version: Int): Boolean {
    return true
}